home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / zoo2 / part02 < prev    next >
Encoding:
Internet Message Format  |  1989-02-01  |  49.3 KB

  1. Subject:  v17i065:  Zoo archive program, Part02/10
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Rahul Dhesi <bsu-cs!dhesi@iuvax.cs.indiana.edu>
  6. Posting-number: Volume 17, Issue 65
  7. Archive-name: zoo2/part02
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 2 (of 10)."
  16. # Wrapped by rsalz@papaya.bbn.com on Thu Feb  2 18:03:57 1989
  17. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  18. if test -f 'Copyright' -a "${1}" != "-c" ; then 
  19.   echo shar: Will not clobber existing file \"'Copyright'\"
  20. else
  21. echo shar: Extracting \"'Copyright'\" \(3768 characters\)
  22. sed "s/^X//" >'Copyright' <<'END_OF_FILE'
  23. X
  24. X                            COPYRIGHT
  25. X
  26. X
  27. XThe following rules apply only to the zoo archiver itself.
  28. XCurrently, all extract-only programs, and all supporting utili-
  29. Xties, are fully in the public domain and are expected to remain so
  30. Xfor the forseeable future.
  31. X
  32. X
  33. X               Copyright Statement for Version 1.71
  34. X
  35. XThe distribution restrictions placed on zoo versions 1.71 and ear-
  36. Xlier are now relaxed.  Version 1.71 and earlier source and the
  37. XAmigaDOS and MS-DOS binary files may be distributed for any pur-
  38. Xpose, whether commercial or noncommercial, by anybody, provided
  39. X(a) the files are distributed unmodified and (b) the recipient is
  40. Xnotified in advance of being provided the software that "version
  41. X1.71 is an outdated version and version 2.00 and higher versions
  42. Xare now available from other sources".  However, creation and dis-
  43. Xtribution of any derivative work is governed by the copyright
  44. Xstatement for versions 2.00 and 2.01.
  45. X
  46. X
  47. X          Copyright Statement for Versions 2.00 and 2.01
  48. X
  49. XThe following conditions apply to the C source code, the MS-DOS
  50. Xsupport package, and to the MS-DOS executable code.  Distribution
  51. Xconditions for J. Brian Waters's AmigaDOS implementation may
  52. Xdiffer and will be stated in the copyright statement accompanying
  53. Xit.
  54. X
  55. X"This program" refers to versions 2.00 and 2.01 and separately to
  56. Xeach subsequent version of the Zoo archiver and to all derivative
  57. Xworks thereof.  "Distribution right" means any copyright, compila-
  58. Xtion copyright, license, or other right to control distribution or
  59. Xcopying.  "Compiled code" means software that can be executed by a
  60. Xcomputer system.
  61. X
  62. XThis program is copyrighted but its distribution for noncommercial
  63. Xpurposes is permitted, with the following restrictions.
  64. X
  65. X   - You are prohibited from distributing this program as part of
  66. X     any package over which you claim a distribution right.  This
  67. X     restriction does not apply if any distribution right is
  68. X     claimed only over individual items that you own or for which
  69. X     the distribution right has been explicitly assigned to you,
  70. X     and not over the package as a collection.
  71. X
  72. X   - You are prohibited from making this program available for
  73. X     downloading via telecommunications if you charge a total of
  74. X     more than $8.00 per hour at 1200 bps during evening and night
  75. X     hours.
  76. X
  77. X   - You are prohibited from distributing this program as compiled
  78. X     code unless you also distribute the source code from which
  79. X     the compiled code was obtained.  This restriction does not
  80. X     apply if the compiled code was created by me.
  81. X
  82. X   - You are prohibited from creating, from this program, any
  83. X     derivative work over which you claim a distribution right.
  84. X
  85. X   - You are prohibited from creating from this program, whether
  86. X     deliberately or through negligence, any derivative work that
  87. X     violates the compatibility goals stated in the user manual
  88. X     for this program.
  89. X
  90. X   - You may use this program, and any derivative works that you
  91. X     create, internally within your own organization free of
  92. X     charge.  You may distribute such derivative works outside
  93. X     your organization provided you adhere to all other conditions
  94. X     of this copyright policy.
  95. X
  96. XThe above restrictions may be relaxed by special agreement; please
  97. Xcontact me for details.
  98. X
  99. X
  100. X                              -- Rahul Dhesi 1988/08/25
  101. X                                 UUCP:    iuvax!bsu-cs!dhesi or
  102. X                                          pur-ee!bsu-cs!dhesi
  103. X                                 GEnie:   DHESI
  104. X                                 Plink:   OLS806
  105. X                                 Phone:   +1 317 285 8641 daytime EST
  106. X                                 US mail: 720 W. Centennial Ave #15,
  107. X                                          Muncie, Indiana 47303
  108. END_OF_FILE
  109. if test 3768 -ne `wc -c <'Copyright'`; then
  110.     echo shar: \"'Copyright'\" unpacked with wrong size!
  111. fi
  112. # end of 'Copyright'
  113. fi
  114. if test -f 'addfname.c' -a "${1}" != "-c" ; then 
  115.   echo shar: Will not clobber existing file \"'addfname.c'\"
  116. else
  117. echo shar: Extracting \"'addfname.c'\" \(3539 characters\)
  118. sed "s/^X//" >'addfname.c' <<'END_OF_FILE'
  119. X#ifndef LINT
  120. Xstatic char sccsid[]="@(#) addfname.c 2.11 88/02/06 20:17:17";
  121. X#endif /* LINT */
  122. X
  123. X/*
  124. XCopyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  125. X(C) Copyright 1988 Rahul Dhesi -- All rights reserved
  126. X*/
  127. X#include "options.h"
  128. X
  129. X/* Adds a filename to global list.  (This global list will eventually
  130. Xbe searched by the inlist() function.)  The second and subsequent
  131. Xparameters suppplied are stored with the name of the file and 
  132. Xreturned by inlist. */
  133. X
  134. X#include "zooio.h"
  135. X#include "various.h"
  136. X#include "zoo.h"
  137. X#include "zoofns.h"
  138. X#include "zoomem.h" /* to get LIST_SIZE */
  139. X
  140. Xstatic struct item *fentry[LIST_SIZE];
  141. Xstatic int lastname = 0;                  /* index of last name */
  142. X
  143. Xstruct item {              /* global filename list entry */
  144. X   char *fname;
  145. X   long position;
  146. X   unsigned int date;
  147. X   unsigned int time;
  148. X    unsigned vflag;
  149. X    unsigned version_no;
  150. X};
  151. X
  152. Xvoid addfname(fname, position, date, time, vflag, version_no)
  153. Xchar *fname;
  154. Xlong position;
  155. Xunsigned int date, time;
  156. Xunsigned vflag;
  157. Xunsigned version_no;
  158. X{
  159. X   if (lastname == 0)
  160. X      fentry[lastname] = (struct item *) emalloc (sizeof(struct item));
  161. X
  162. X   /* keep a few empty spaces at end to avoid off by one errors */
  163. X   if (lastname >= LIST_SIZE - 3)
  164. X      memerr();
  165. X
  166. X   fentry[lastname]->fname = strdup(fname);
  167. X   fentry[lastname]->position = position;
  168. X   fentry[lastname]->date = date;
  169. X   fentry[lastname]->time = time;
  170. X    fentry[lastname]->vflag = vflag;
  171. X    fentry[lastname]->version_no = version_no;
  172. X   lastname++;
  173. X   /* allocate memory for empty entry at end */
  174. X   fentry[lastname] = (struct item *) emalloc (sizeof(struct item)); 
  175. X} /* addfname */
  176. X
  177. X/* inlist() */
  178. X/* Examines global list built by addfname() to see if supplied filename
  179. Xis in the list.  
  180. X
  181. XIf found, returns the file's position within the archive as the function 
  182. Xvalue and the date, time, version flag, and version number as parameters.
  183. XIf not found, returns -1.  Also returns the highest version no. seen
  184. Xfor this filename and the vflag associated with that version.
  185. X
  186. XA simple sequential search is done.
  187. X
  188. XIf justname is nonzero, then the search is for the filename only
  189. Xwithout the directory prefix;  else it is for the full
  190. Xpathname.
  191. X*/
  192. X
  193. Xlong inlist (fname, date, time, this_version_no, high_vflag, 
  194. X                    high_version_no, high_pos, justname)
  195. Xchar *fname;
  196. Xunsigned int *date, *time;
  197. Xunsigned *high_vflag;
  198. Xunsigned *this_version_no;
  199. Xunsigned *high_version_no;
  200. Xlong *high_pos;
  201. Xint justname;
  202. X{
  203. X   register int i = 0;
  204. X
  205. X    *high_version_no = 0;
  206. X    if (justname)
  207. X        fname = nameptr (fname);                    /* if directory wanted */
  208. X   fentry[lastname]->fname = fname;          /* sentinel */
  209. X    fentry[lastname]->version_no = 0;
  210. X
  211. X#ifdef IGNORECASE
  212. X#define    COMPARE    strcmpi
  213. X#else
  214. X#define    COMPARE    strcmp
  215. X#endif
  216. X
  217. X   while (COMPARE(fname,
  218. X            (justname ? nameptr (fentry[i]->fname) : fentry[i]->fname)) != 0) {
  219. X      i++;
  220. X   }
  221. X
  222. X   if (i == lastname)
  223. X      return (-1L);
  224. X   else {
  225. X        int j;
  226. X        *date = fentry[i]->date;
  227. X        *time = fentry[i]->time;
  228. X        *high_pos = fentry[i]->position;
  229. X        *high_vflag = fentry[i]->vflag;
  230. X        for (j = i; j < lastname; j++) {    /* find highest version no. for file */
  231. X            if (COMPARE(fname,
  232. X                (justname ? nameptr (fentry[j]->fname) : fentry[j]->fname)) == 0) {
  233. X                if (*high_version_no < fentry[j]->version_no) {
  234. X                    *high_version_no = fentry[j]->version_no;
  235. X                    *high_vflag = fentry[j]->vflag;
  236. X                    *high_pos = fentry[j]->position;
  237. X                    *date = fentry[j]->date;
  238. X                    *time = fentry[j]->time;
  239. X                }
  240. X            }
  241. X        }
  242. X        *this_version_no = fentry[i]->version_no;
  243. X      return (fentry[i]->position);
  244. X   }
  245. X} /* inlist() */
  246. END_OF_FILE
  247. if test 3539 -ne `wc -c <'addfname.c'`; then
  248.     echo shar: \"'addfname.c'\" unpacked with wrong size!
  249. fi
  250. # end of 'addfname.c'
  251. fi
  252. if test -f 'basename.c' -a "${1}" != "-c" ; then 
  253.   echo shar: Will not clobber existing file \"'basename.c'\"
  254. else
  255. echo shar: Extracting \"'basename.c'\" \(3229 characters\)
  256. sed "s/^X//" >'basename.c' <<'END_OF_FILE'
  257. X#ifndef LINT
  258. X/* @(#) basename.c 2.2 87/12/27 13:42:40 */
  259. Xstatic char sccsid[]="@(#) basename.c 2.2 87/12/27 13:42:40";
  260. X#endif /* LINT */
  261. X
  262. X/*
  263. XCopyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  264. X*/
  265. X
  266. X#include "options.h"
  267. X#include "zooio.h"
  268. X#include "zoo.h"
  269. X#include "parse.h"
  270. X#include "various.h"
  271. X#include "zoofns.h"
  272. X#include "debug.h"
  273. X#include "assert.h"
  274. X
  275. X/* This function strips device/directory information from
  276. Xa pathname and returns just the plain filename */
  277. Xvoid basename (pathname, fname)
  278. Xchar *pathname;
  279. Xchar fname[];
  280. X{
  281. X   strcpy (fname, nameptr (pathname));
  282. X}
  283. X
  284. X/* Set of legal MSDOS filename characters.  The working of cvtchr() depends
  285. Xon the order of the first few characters here.  In particular, '_' is
  286. Xpositioned so '.' gets converted to it. */
  287. Xstatic char legal[] = 
  288. X"tabcdefghijklmnopqrs_uvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@^`{}~!#$%&'()-";
  289. X
  290. X/****************
  291. Xcvtchr() converts a character to a lowercase alphabetic character in
  292. Xa somewhat random way.  
  293. X*/
  294. X#define  cvtchr(ch)        legal[(ch & 0xff) % 26]
  295. X
  296. X/***************
  297. Xcleanup() cleans up a string so it contains only legal MSDOS filename
  298. Xcharacters.  Any other characters are converted to an underscore.
  299. XIf the filename is null or if it begins with a dot, it is fixed.
  300. XAll dots are also converted.
  301. X*/
  302. X
  303. X#ifdef LINT_ARGS
  304. Xvoid cleanup (char *);
  305. X#endif
  306. X
  307. Xvoid cleanup (p)
  308. Xchar *p;
  309. X{
  310. X   assert(p != NULL);
  311. X   if (*p == '\0')
  312. X      strcpy (p, "X");
  313. X   if (*p == '.')
  314. X      *p = '_';
  315. X   while (*p != '\0') {
  316. X      if (strchr (legal, *p) == NULL) {   /* if invalid character */
  317. X         *p = cvtchr(*p);
  318. X      }
  319. X      p++;
  320. X   }
  321. X}
  322. X/* This function strips device/directory information from a pathname,
  323. Xforces the remaining filename to MSDOS format, and returns it.  Any
  324. Xillegal characters are fixed.
  325. X*/
  326. Xvoid dosname (pathname, fname)
  327. Xchar *pathname;
  328. Xchar fname[];
  329. X{
  330. X   struct path_st path_st;
  331. X   parse (&path_st, pathname);
  332. X   strcpy (fname, path_st.fname);
  333. X   cleanup (fname);
  334. X
  335. X#ifdef VER_CH  /* remove any trailing extension field */
  336. X   if (path_st.ext[0] != '\0')
  337. X      strip_ver (path_st.ext);
  338. X#endif
  339. X
  340. X   /* extension could have been nulled, so we test again */
  341. X   if (path_st.ext[0] != '\0') {
  342. X      cleanup (path_st.ext);
  343. X      strcat (fname, ".");
  344. X      strcat (fname, path_st.ext);
  345. X   }
  346. X
  347. X#ifdef SPECMOD
  348. X   specfname (fname);
  349. X#endif
  350. X}
  351. X
  352. X/* rootname() */
  353. X/* Accepts a pathname.  Returns the root filename, i.e., with both the
  354. Xdirectory path and the extension stripped. */
  355. X
  356. Xvoid rootname (path, root)
  357. Xchar *path, *root;
  358. X{
  359. X   char *p;
  360. X   static char dot[] = {EXT_CH, '\0'};
  361. X   strcpy(root, nameptr(path));           /* copy all but path prefix */
  362. X   p = findlast(root, dot);               /* find last dot */
  363. X   if (p != NULL)                         /* if found ... */
  364. X      *p = '\0';                          /* ... null it out */
  365. X}
  366. X
  367. X/* nameptr() */
  368. X/* Accepts a pathname.  Returns a pointer to the filename within
  369. Xthat pathname.
  370. X*/
  371. X
  372. Xchar *nameptr (path)
  373. Xchar *path;
  374. X{
  375. X   char *t;
  376. X   t = findlast (path, PATH_SEP);   /* last char separating device/directory */
  377. X   debug ((printf ("nameptr:  findlast returned ptr to string [%s].\n",t)))
  378. X   if (t == NULL)                /* no separator */
  379. X      return (path);
  380. X   else {
  381. X      return (t+1);
  382. X   }
  383. X}
  384. END_OF_FILE
  385. if test 3229 -ne `wc -c <'basename.c'`; then
  386.     echo shar: \"'basename.c'\" unpacked with wrong size!
  387. fi
  388. # end of 'basename.c'
  389. fi
  390. if test -f 'fiz.1' -a "${1}" != "-c" ; then 
  391.   echo shar: Will not clobber existing file \"'fiz.1'\"
  392. else
  393. echo shar: Extracting \"'fiz.1'\" \(3849 characters\)
  394. sed "s/^X//" >'fiz.1' <<'END_OF_FILE'
  395. X.\" @(#) fiz.1 1.2 88/01/31 23:22:04
  396. X.\"
  397. X.\" For formatting with nroff:
  398. X.\"   nroff -man fiz.1
  399. X.\"
  400. X.TH FIZ 1 "Jan 31, 1988"
  401. X.SH NAME
  402. Xfiz \- analyze damaged zoo archive for data revovery
  403. X.SH SYNOPSIS
  404. X.I fiz
  405. X.RB archive[ .zoo ]
  406. X.SH DESCRIPTION
  407. X.I Fiz
  408. Xis used to analyze damaged
  409. X.I zoo
  410. Xarchives and locate directory entries and file data in them.
  411. XThe current version of 
  412. X.I fiz
  413. Xis 2.0 and it is meant to be used in conjunction with
  414. X.I zoo
  415. Xversion 2.0.
  416. X.I Fiz
  417. Xmakes no assumptions about archive structure.  Instead, it simply
  418. Xsearches the entire subject archive for tag values
  419. Xthat mark the locations of directory entries and file data.
  420. XIn a 
  421. X.I zoo
  422. Xarchive, a
  423. X.I directory entry
  424. Xcontains information about a stored file such as its name, whether 
  425. Xcompressed or not, and its timestamp.  The
  426. X.I file data
  427. Xare the actual data for the archived file, and may be
  428. Xeither the original data, or the result of compressing the file.
  429. X.PP
  430. XFor each directory entry found,
  431. X.I fiz
  432. Xprints where in the archive it is located, the directory path and
  433. Xfilename(s) found in it, whether the directory entry appears
  434. Xto be corrupted (indicated by [*CRC Error*]), and the value of
  435. Xthe pointer to the file data that is found in the directory entry.
  436. XFor each block of file data found in the archive,
  437. X.I fiz
  438. Xprints where in the archive the block begins.  In the case of
  439. Xan undamaged archive, the pointer to file data found in
  440. Xa directory entry will correspond to where
  441. X.I fiz
  442. Xactually locates the data.  Here is some sample output from 
  443. X.I fiz:
  444. X.PP
  445. X.nf
  446. X****************
  447. X    2526: DIR  [changes] ==>   95
  448. X    2587: DATA
  449. X****************
  450. X    3909: DIR  [copyrite] ==> 1478
  451. X    3970: DATA
  452. X    4769: DATA
  453. X****************
  454. X.fi
  455. X.sp 1
  456. XIn such output, 
  457. X.B DIR
  458. Xindicates where 
  459. X.I fiz
  460. Xfound a directory entry in the archive, and
  461. X.B DATA
  462. Xindicates where 
  463. X.I fiz
  464. Xfound file data in the archive.  Filenames located by
  465. X.I fiz
  466. Xare enclosed in square brackets, and the notation
  467. X"==>   95" indicates that the directory entry found by
  468. X.I fiz
  469. Xat position 2526 has a file data pointer to
  470. Xposition 95.  In actuality,
  471. X.I fiz
  472. Xfound file data at positions 2587, 3970, and
  473. X4769.  Since 
  474. X.I fiz
  475. Xfound only two directory entries, and each directory entry corresponds
  476. Xto one file, one of the file data positions is an artifact.
  477. X.PP
  478. XOnce the locations of directory entries and file data are found, the
  479. X.B @
  480. Xmodifier to
  481. X.I "zoo's"
  482. Xarchive list and extract commands can be used and
  483. Xthe archive contents selectively listed or extracted,
  484. Xskipping the damaged portion.  This is further described
  485. Xin the documentation for
  486. X.I zoo(1).
  487. X.PP
  488. XIn the above case, commands to try giving to 
  489. X.I zoo
  490. Xmight be
  491. X.B x@2526,2587
  492. X(extract beginning at position 2526, and get file data
  493. Xfrom position 2587),
  494. X.B x@3090,3970
  495. X(extract at 3090, get data from 3970)
  496. Xand
  497. X.B x@3909,4769
  498. X(extract at 3909, get data from 4769).  Once a correctly-matched
  499. Xdirectory entry/file data pair is found,
  500. X.I zoo
  501. Xwill in most cases synchronize with and correctly extract all files
  502. Xsubsequently found in the archive.  Trial and error should allow
  503. Xall undamaged files to be extracted.
  504. XAlso note that self-extracting archives created using
  505. X.I sez
  506. X(the Self-Extracting
  507. X.I Zoo
  508. Xutility for MS-DOS), which are normally executed on an MS-DOS
  509. Xsystem for extraction, can
  510. Xbe extracted on non-MSDOS systems in a similar way.
  511. X.PP
  512. X.SH "SEE ALSO"
  513. Xzoo(1)
  514. X.SH BUGS
  515. XRandom byte patterns can occasionally be incorrectly recognized
  516. Xas tag values.  This occurs very rarely, however, and trial
  517. Xand error will usually permit all undamaged data to be
  518. Xextracted.
  519. X.SH DIAGNOSTICS
  520. X.I Fiz
  521. Xalways exits with a status code of 0.
  522. X.SH "FUTURE DIRECTIONS"
  523. XAutomation of data recovery from a damaged archive is potentially
  524. Xachievable.  However, since damaged archives occur only rarely,
  525. X.I fiz
  526. Xas it currently stands is unlikely to change much in the
  527. Xnear future.
  528. X.SH AUTHOR
  529. XRahul Dhesi
  530. END_OF_FILE
  531. if test 3849 -ne `wc -c <'fiz.1'`; then
  532.     echo shar: \"'fiz.1'\" unpacked with wrong size!
  533. fi
  534. # end of 'fiz.1'
  535. fi
  536. if test -f 'fiz.man' -a "${1}" != "-c" ; then 
  537.   echo shar: Will not clobber existing file \"'fiz.man'\"
  538. else
  539. echo shar: Extracting \"'fiz.man'\" \(4227 characters\)
  540. sed "s/^X//" >'fiz.man' <<'END_OF_FILE'
  541. X
  542. X
  543. X
  544. XFIZ(1)              **IX Programmer's Manual               FIZ(1)
  545. X
  546. X
  547. X
  548. XNAME
  549. X     fiz - analyze damaged zoo archive for data revovery
  550. X
  551. XSYNOPSIS
  552. X     fiz archive[.zoo]
  553. X
  554. XDESCRIPTION
  555. X     Fiz is used to analyze damaged zoo archives and locate
  556. X     directory entries and file data in them.  The current ver-
  557. X     sion of fiz is 2.0 and it is meant to be used in conjunction
  558. X     with zoo version 2.0.  Fiz makes no assumptions about
  559. X     archive structure.  Instead, it simply searches the entire
  560. X     subject archive for tag values that mark the locations of
  561. X     directory entries and file data.  In a zoo archive, a direc-
  562. X     tory entry contains information about a stored file such as
  563. X     its name, whether compressed or not, and its timestamp.  The
  564. X     file data are the actual data for the archived file, and may
  565. X     be either the original data, or the result of compressing
  566. X     the file.
  567. X
  568. X     For each directory entry found, fiz prints where in the
  569. X     archive it is located, the directory path and filename(s)
  570. X     found in it, whether the directory entry appears to be cor-
  571. X     rupted (indicated by [*CRC Error*]), and the value of the
  572. X     pointer to the file data that is found in the directory
  573. X     entry.  For each block of file data found in the archive,
  574. X     fiz prints where in the archive the block begins.  In the
  575. X     case of an undamaged archive, the pointer to file data found
  576. X     in a directory entry will correspond to where fiz actually
  577. X     locates the data.  Here is some sample output from fiz:
  578. X
  579. X     ****************
  580. X         2526: DIR  [changes] ==>   95
  581. X         2587: DATA
  582. X     ****************
  583. X         3909: DIR  [copyrite] ==> 1478
  584. X         3970: DATA
  585. X         4769: DATA
  586. X     ****************
  587. X
  588. X     In such output, DIR indicates where fiz found a directory
  589. X     entry in the archive, and DATA indicates where fiz found
  590. X     file data in the archive.  Filenames located by fiz are
  591. X     enclosed in square brackets, and the notation "==>   95"
  592. X     indicates that the directory entry found by fiz at position
  593. X     2526 has a file data pointer to position 95.  In actuality,
  594. X     fiz found file data at positions 2587, 3970, and 4769.
  595. X     Since fiz found only two directory entries, and each direc-
  596. X     tory entry corresponds to one file, one of the file data
  597. X     positions is an artifact.
  598. X
  599. X
  600. X
  601. X
  602. X
  603. XPrinted 2/7/88            Jan 31, 1988                          1
  604. X
  605. X
  606. X
  607. X
  608. X
  609. X
  610. XFIZ(1)              **IX Programmer's Manual               FIZ(1)
  611. X
  612. X
  613. X
  614. X     Once the locations of directory entries and file data are
  615. X     found, the @ modifier to zoo's archive list and extract com-
  616. X     mands can be used and the archive contents selectively
  617. X     listed or extracted, skipping the damaged portion.  This is
  618. X     further described in the documentation for zoo(1).
  619. X
  620. X     In the above case, commands to try giving to zoo might be
  621. X     x@2526,2587 (extract beginning at position 2526, and get
  622. X     file data from position 2587), x@3090,3970 (extract at 3090,
  623. X     get data from 3970) and x@3909,4769 (extract at 3909, get
  624. X     data from 4769).  Once a correctly-matched directory
  625. X     entry/file data pair is found, zoo will in most cases syn-
  626. X     chronize with and correctly extract all files subsequently
  627. X     found in the archive.  Trial and error should allow all
  628. X     undamaged files to be extracted.  Also note that self-
  629. X     extracting archives created using sez (the Self-Extracting
  630. X     Zoo utility for MS-DOS), which are normally executed on an
  631. X     MS-DOS system for extraction, can be extracted on non-MSDOS
  632. X     systems in a similar way.
  633. X
  634. XSEE ALSO
  635. X     zoo(1)
  636. X
  637. XBUGS
  638. X     Random byte patterns can occasionally be incorrectly recog-
  639. X     nized as tag values.  This occurs very rarely, however, and
  640. X     trial and error will usually permit all undamaged data to be
  641. X     extracted.
  642. X
  643. XDIAGNOSTICS
  644. X     Fiz always exits with a status code of 0.
  645. X
  646. XFUTURE DIRECTIONS
  647. X     Automation of data recovery from a damaged archive is poten-
  648. X     tially achievable.  However, since damaged archives occur
  649. X     only rarely, fiz as it currently stands is unlikely to
  650. X     change much in the near future.
  651. X
  652. XAUTHOR
  653. X     Rahul Dhesi
  654. X
  655. X
  656. X
  657. X
  658. X
  659. X
  660. X
  661. X
  662. X
  663. X
  664. X
  665. X
  666. X
  667. X
  668. X
  669. XPrinted 2/7/88            Jan 31, 1988                          2
  670. X
  671. X
  672. X
  673. END_OF_FILE
  674. if test 4227 -ne `wc -c <'fiz.man'`; then
  675.     echo shar: \"'fiz.man'\" unpacked with wrong size!
  676. fi
  677. # end of 'fiz.man'
  678. fi
  679. if test -f 'generic.c' -a "${1}" != "-c" ; then 
  680.   echo shar: Will not clobber existing file \"'generic.c'\"
  681. else
  682. echo shar: Extracting \"'generic.c'\" \(3350 characters\)
  683. sed "s/^X//" >'generic.c' <<'END_OF_FILE'
  684. X#ifndef LINT
  685. Xstatic char genericid[]="@(#) generic.c 2.2 88/01/24 12:44:03";
  686. X#endif /* LINT */
  687. X
  688. X/* 
  689. XGeneric template for machine-dependent functions.
  690. X
  691. XThe contents of this file are hereby released to the public domain
  692. X
  693. X                                            -- Rahul Dhesi 1988/01/24
  694. X
  695. XFunctions in this file have not yet been revised to work with zoo 
  696. Xversion 2.0.  To port zoo to a new system, look in files sysv.c and bsd.c 
  697. Xto see which system-dependent functions may be needed.
  698. X*/
  699. X
  700. X/****************
  701. Xfunction trunc() truncates a file.
  702. X*/
  703. X
  704. Xint trunc (handle)
  705. Xint handle;
  706. X{
  707. X   /* code to truncate file goes here -- may be left empty */
  708. X}
  709. X
  710. X/*****************
  711. XFunction gettime() or getutime() gets the date and time of the file handle 
  712. Xor filename supplied.  Date and time is in MSDOS format.
  713. X*/
  714. X#ifdef GETUTIME
  715. Xgetutime (fname, date, time)
  716. Xchar *fname;
  717. X#else
  718. Xgettime (handle,date,time)
  719. Xint handle;
  720. X#endif
  721. Xunsigned *date, *time;
  722. X{
  723. X   *date = *time = 0; /* not yet implemented */
  724. X}
  725. X
  726. X/*****************
  727. XFunction settime() or setutime() sets the date and time of the file handle
  728. Xor filename supplied.  Date and time is in MSDOS format.
  729. X*/
  730. X#ifdef NIXTIME
  731. Xint setutime(path,date,time)
  732. Xchar *path;
  733. X#else
  734. Xint settime(handle, date, time)
  735. Xint handle;
  736. X#endif
  737. Xunsigned int date, time;
  738. X{
  739. X   /* not yet implemented */
  740. X}
  741. X
  742. X/*****************
  743. XFunction mktemp() accepts a template of the form `baseXXXXXX' where
  744. Xbase is an arbitrary string, and returns a unique temporary filename.
  745. XIf template is not correct, it is returned unchanged.
  746. X*/
  747. Xchar *mktemp(template)
  748. Xchar *template;
  749. X{
  750. X#ifndef NDEBUG
  751. X   if (instr(template, "XXXXXX") == -1)
  752. X      prterror ('w', "Incorrect template [%s] supplied to mktemp().\n",
  753. X         template);
  754. X#endif
  755. X
  756. X   strcpy(&template[instr(template, "XXXXXX")],"z.@@@");
  757. X   return (template);
  758. X}
  759. X
  760. X/*****************
  761. XFunction isadir() or isuadir() returns 1 if supplied handle or 
  762. Xfilename is a directory or other special file that should not be 
  763. Xarchived, else it returns 0.
  764. X*/
  765. X
  766. X#ifdef CHEKDIR
  767. Xint isadir(han)
  768. Xint han;
  769. X{
  770. X   return (0); /* by default assume never a directory */
  771. X}
  772. X#endif
  773. X
  774. X#ifdef CHEKUDIR
  775. Xint isuadir(path)
  776. Xchar *path;
  777. X{
  778. X   return (0); /* by default assume never a directory */
  779. X}
  780. X#endif
  781. X
  782. X/****************
  783. XFunction fixfname() converts the supplied filename to a syntax
  784. Xlegal for the host system.  It is used during extraction to make sure
  785. Xthat a file can be extracted even if a badly-implemented archiver
  786. Xstored it with an illegal filename.
  787. X*/
  788. X
  789. Xchar *fixfname(fname)
  790. Xchar *fname;
  791. X{
  792. X   return (fname); /* default is no-op */
  793. X}
  794. X
  795. X/*****************
  796. XFunction nextfile() is effectively a no-op.  Any wildcard expansion 
  797. Xmust have been done before Zoo receives the arguments.
  798. X*/
  799. X
  800. X#define FMAX 1
  801. Xchar *nextfile (what, filespec, fileset)
  802. Xint what;                        /* whether to initialize or match      */
  803. Xregister char *filespec;         /* filespec to match if initializing   */
  804. Xregister int fileset;            /* which set of files                  */
  805. X{
  806. X   static int first_time [FMAX+1];
  807. X   static char saved_fspec [FMAX+1][PATHSIZE];  /* our own copy of filespec */
  808. X
  809. X   if (what == 0) {
  810. X      strcpy (saved_fspec[fileset], filespec);  /* save the filespec */
  811. X      first_time[fileset] = 1;
  812. X      return (NULL);
  813. X   }
  814. X
  815. X   if (first_time[fileset]) {
  816. X      first_time[fileset] = 0;
  817. X      return (saved_fspec[fileset]);
  818. X   } else {
  819. X      return (NULL);
  820. X   }
  821. X}
  822. END_OF_FILE
  823. if test 3350 -ne `wc -c <'generic.c'`; then
  824.     echo shar: \"'generic.c'\" unpacked with wrong size!
  825. fi
  826. # end of 'generic.c'
  827. fi
  828. if test -f 'getfile.c' -a "${1}" != "-c" ; then 
  829.   echo shar: Will not clobber existing file \"'getfile.c'\"
  830. else
  831. echo shar: Extracting \"'getfile.c'\" \(4549 characters\)
  832. sed "s/^X//" >'getfile.c' <<'END_OF_FILE'
  833. X#ifndef LINT
  834. Xstatic char sccsid[]="@(#) getfile.c 2.7 88/01/24 12:44:23";
  835. X#endif /* LINT */
  836. X
  837. X/*
  838. XCopyright (C) 1986, 1987 Rahul Dhesi -- All rights reserved
  839. X(C) Copyright 1988 Rahul Dhesi -- All rights reserved
  840. X*/
  841. X
  842. X#include "options.h"
  843. X/*
  844. XThis function copies n characters from the source file to the destination
  845. X
  846. XInput:   out_f:            destination file
  847. X         in_f:             source file
  848. X         count:         count of characters to copy
  849. X         docrc:         0 if crc not wanted
  850. X
  851. XIf count is -1, copying is done until eof is encountered.
  852. X
  853. XThe source file is transferred to the current file pointer position in the
  854. Xdestination file, using the handles provided.  Function return value is 0
  855. Xif no error, 2 if write error, and 3 if read error.
  856. X
  857. XIf docrc is not 0, the global variable crccode is updated via addbfcrc().
  858. XThis is done even if the output is to the null device.
  859. X
  860. XIf UNBUF_IO is defined, and if more than UNBUF_LIMIT bytes are 
  861. Xbeing transferred or copying is to end of file, the data transfer 
  862. Xis done using low-level read() and write() functions, which must 
  863. Xbe defined elsewhere.  File descriptors are obtained for this 
  864. Xpurpose using the fileno() macro, which must be provided elsewhere 
  865. Xtoo.  This is meant to provide greater efficiency on some systems.
  866. XThe files of type ZOOFILE are synchronized with their file 
  867. Xdescriptors by doing a reasonable number of seeks and other
  868. Xmiscellaneous operations before and after the transfer.  Such 
  869. Xsimultaneous use of buffered and unbuffered files is not
  870. Xportable and should not be used without extensive testing.
  871. X*/
  872. X
  873. X#ifdef UNBUF_IO
  874. Xint read PARMS ((int, VOIDPTR, unsigned));
  875. Xint write PARMS ((int, VOIDPTR, unsigned));
  876. Xlong lseek PARMS ((int, long, int));
  877. Xlong tell PARMS ((int));
  878. X#endif /* UNBUF_IO */
  879. X
  880. X#include "zoo.h"        /* satisfy declarations in zooio.h */
  881. X#include "zooio.h"
  882. X#include "various.h"
  883. X#include "zoofns.h"
  884. X#include "zoomem.h"
  885. X
  886. Xint getfile (in_f, out_f, count, docrc)
  887. XZOOFILE in_f, out_f;
  888. Xlong count;
  889. Xint docrc;
  890. X{
  891. X   register int how_much;
  892. X#ifdef UNBUF_IO
  893. X    int in_d, out_d;    /* file descriptors for unbuffered I/O */
  894. X#endif /* UNBUF_IO */
  895. X
  896. X#ifdef UNBUF_IO
  897. X    if (out_f != NULLFILE && (count == -1 || count > UNBUF_LIMIT)) {
  898. X        in_d = fileno (in_f);        /* get ..                        */
  899. X        out_d = fileno (out_f);        /* ... file descriptors        */
  900. X
  901. X        /* Synchronize buffered and unbuffered files */
  902. X        zooseek (in_f, zootell (in_f), 0);
  903. X        zooseek (out_f, zootell (out_f), 0);
  904. X
  905. X#if 0
  906. X        lseek (in_d, zootell (in_f), 0);
  907. X        lseek (out_d, zootell (out_f), 0);
  908. X#endif
  909. X
  910. X        if (count == -1) {
  911. X            while ((how_much = read (in_d, out_buf_adr, MEM_BLOCK_SIZE)) > 0) {
  912. X                if (how_much == -1 ||
  913. X                        write (out_d, out_buf_adr, how_much) != how_much)
  914. X                    return (2);
  915. X                if (docrc)
  916. X                    addbfcrc (out_buf_adr,how_much);
  917. X            }
  918. X            zooseek (in_f, tell (in_d), 0);        /* resynch    */
  919. X            zooseek (out_f, tell (out_d), 0);    /* resynch    */
  920. X
  921. X#ifndef NDEBUG
  922. X            if (ftell (in_f) != tell (in_d) || ftell (out_f) != tell (out_d)) {
  923. X                prterror ('w', "seek mismatch in copy to EOF\n");
  924. X                printf ("in_f =%6ld, in_d =%6ld\n", ftell (in_f),  tell (in_d));
  925. X                printf ("out_f=%6ld, out_d=%6ld\n", ftell (out_f), tell (out_d));
  926. X            }
  927. X#endif /* NDEBUG */
  928. X
  929. X            return (0);
  930. X        }
  931. X
  932. X        while (count > 0) {
  933. X            if (count > MEM_BLOCK_SIZE)
  934. X                how_much = MEM_BLOCK_SIZE;
  935. X            else
  936. X                how_much = (int) count;
  937. X            count -= how_much;
  938. X            if (read (in_d, out_buf_adr, how_much) != how_much)
  939. X                return (3);
  940. X            if (docrc)
  941. X                addbfcrc (out_buf_adr, how_much);
  942. X            if (write (out_d, out_buf_adr, how_much) != how_much)
  943. X                return (2);
  944. X        }
  945. X        zooseek (in_f, tell (in_d), 0);        /* resynch    */
  946. X        zooseek (out_f, tell (out_d), 0);    /* resynch    */
  947. X#ifndef NDEBUG
  948. X        if (ftell (in_f) != tell (in_d) || ftell (out_f) != tell (out_d))
  949. X             prterror ('w', "seek mismatch in fixed length copy\n");
  950. X#endif /* NDEBUG */
  951. X        return (0);
  952. X    }
  953. X#endif /* UNBUF_IO */
  954. X
  955. X   if (count == -1) {
  956. X      while ((how_much = zooread (in_f, out_buf_adr, MEM_BLOCK_SIZE)) > 0) {
  957. X         if (how_much == -1 ||
  958. X               zoowrite (out_f, out_buf_adr, how_much) != how_much)
  959. X            return (2);
  960. X         if (docrc)
  961. X            addbfcrc (out_buf_adr,how_much);
  962. X      }
  963. X      return (0);
  964. X   }
  965. X
  966. X   while (count > 0) {
  967. X      if (count > MEM_BLOCK_SIZE)
  968. X         how_much = MEM_BLOCK_SIZE;
  969. X      else
  970. X         how_much = (int) count;
  971. X      count -= how_much;
  972. X      if (zooread (in_f, out_buf_adr, how_much) != how_much)
  973. X         return (3);
  974. X      if (docrc)
  975. X         addbfcrc (out_buf_adr, how_much);
  976. X      if (zoowrite (out_f, out_buf_adr, how_much) != how_much)
  977. X         return (2);
  978. X   }
  979. X   return (0);
  980. X}
  981. END_OF_FILE
  982. if test 4549 -ne `wc -c <'getfile.c'`; then
  983.     echo shar: \"'getfile.c'\" unpacked with wrong size!
  984. fi
  985. # end of 'getfile.c'
  986. fi
  987. if test -f 'makefile' -a "${1}" != "-c" ; then 
  988.   echo shar: Will not clobber existing file \"'makefile'\"
  989. else
  990. echo shar: Extracting \"'makefile'\" \(2601 characters\)
  991. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  992. X# @(#) makefile 2.2 88/01/27 19:37:59 
  993. X#Make Zoo
  994. X#
  995. X#The contents of this makefile are hereby released to the public domain.
  996. X#                                  -- Rahul Dhesi 1986/12/31
  997. X#
  998. X#This makefile should not be invoked directly, because different 
  999. X#targets require different compilation switches.  The standard make
  1000. X#utility does not allow different switches to be specified for each target
  1001. X#(except through recursive invocation, which takes more memory than 
  1002. X#some systems have).  Invoke this makefile through one of the several
  1003. X#shell scripts supplied.  For non *NIX systems, convert the appropriate
  1004. X#shell script to one accepted by your system.
  1005. X#
  1006. X#This makefile expects two macro names, `cswitch' and `extra', to hold
  1007. X#all the switches to be supplied to the C compiler.  It also expects
  1008. X#a macro `ldswitch' to hold the switch for the loader when invoked.
  1009. X#
  1010. X#There is no target for installation.  Just copy the executables
  1011. X#(zoo and fiz) to the appropriate destination directory.
  1012. X#
  1013. X#"make lint" will probably not work.
  1014. X
  1015. XCC = cc
  1016. Xcswitch =
  1017. Xextra = -DBIG_MEM -DNDEBUG
  1018. X
  1019. X#List of all object files created for Zoo
  1020. XZOOOBJS =     addbfcrc.o addfname.o basename.o comment.o crcdefs.o \
  1021. X        getfile.o lzc.o lzd.o machine.o makelist.o misc.o misc2.o \
  1022. X        nextfile.o needed.o options.o parse.o portable.o prterror.o \
  1023. X        version.o zoo.o zooadd.o zooadd2.o zoodel.o zooext.o zoofilt.o \
  1024. X        zoolist.o zoopack.o
  1025. X
  1026. XFIZOBJS = fiz.o addbfcrc.o portable.o crcdefs.o
  1027. X
  1028. X.c.o :
  1029. X    $(CC) $(cswitch) $(extra) $*.c
  1030. X
  1031. Xall : ERROR
  1032. X
  1033. X#doesn't work
  1034. Xlint: $(ZOOOBJS)
  1035. X    lint $(ZOOOBJS)
  1036. X
  1037. Xzoo: $(ZOOOBJS)
  1038. X    $(CC) $(ldswitch) $(ZOOOBJS)
  1039. X
  1040. Xfiz: $(FIZOBJS)
  1041. X    $(CC) $(ldswitch) $(FIZOBJS)
  1042. X
  1043. Xclean :
  1044. X    /bin/rm -f core a.out $(ZOOOBJS) $(FIZOBJS)
  1045. X
  1046. Xlzd.o : lzd.c zoomem.h
  1047. X    $(CC) $(cswitch) $(extra) $*.c
  1048. X
  1049. Xlzc.o : lzc.c zoomem.h
  1050. X    $(CC) $(cswitch) $(extra) $*.c
  1051. X
  1052. Xaddbfcrc.o : addbfcrc.c
  1053. X
  1054. Xaddfname.o : addfname.c
  1055. X
  1056. Xbasename.o : basename.c
  1057. X
  1058. Xcomment.c : zooio.h
  1059. X
  1060. Xcrcdefs.o : crcdefs.c
  1061. X
  1062. Xgetfile.o : getfile.c zoomem.h
  1063. X    $(CC) $(cswitch) $(extra) $*.c
  1064. X
  1065. Xmachine.o : machine.c nixtime.i
  1066. X    $(CC) $(cswitch) $(extra) $*.c
  1067. X
  1068. Xmakelist.o : makelist.c
  1069. X
  1070. Xmisc.c : zooio.h
  1071. X
  1072. Xmisc2.o : misc2.c zoomem.h
  1073. X    $(CC) $(cswitch) $(extra) $*.c
  1074. X
  1075. Xoptions.o : options.c
  1076. X
  1077. Xnextfile.o :  nextfile.c
  1078. X
  1079. Xneeded.o : needed.c
  1080. X
  1081. Xparse.o : parse.c
  1082. X
  1083. Xportable.o : portable.c
  1084. X
  1085. Xprterror.o : prterror.c
  1086. X
  1087. Xzoo.o :   zoo.c zoomem.h errors.i
  1088. X    $(CC) $(cswitch) $(extra) $*.c
  1089. X
  1090. Xzooadd.c : zooio.h
  1091. X
  1092. Xzooadd2.c : zooio.h
  1093. X
  1094. Xzoodel.c : zooio.h
  1095. X
  1096. Xzooext.o : zooext.c  errors.i zooio.h
  1097. X    $(CC) $(cswitch) $(extra) $*.c
  1098. X
  1099. Xzoofilt.o : zoofilt.c zooio.h
  1100. X    $(CC) $(cswitch) $(extra) $*.c
  1101. X
  1102. Xzoolist.c : zooio.h
  1103. X
  1104. Xzoopack.c : zooio.h
  1105. END_OF_FILE
  1106. if test 2601 -ne `wc -c <'makefile'`; then
  1107.     echo shar: \"'makefile'\" unpacked with wrong size!
  1108. fi
  1109. # end of 'makefile'
  1110. fi
  1111. if test -f 'mstime.i' -a "${1}" != "-c" ; then 
  1112.   echo shar: Will not clobber existing file \"'mstime.i'\"
  1113. else
  1114. echo shar: Extracting \"'mstime.i'\" \(2860 characters\)
  1115. sed "s/^X//" >'mstime.i' <<'END_OF_FILE'
  1116. X#ifndef LINT
  1117. Xstatic char mstimeid[]="@(#) mstime.i 2.2 88/01/24 12:47:58";
  1118. X#endif /* LINT */
  1119. X
  1120. X/*
  1121. X(C) Copyright 1987 Rahul Dhesi -- All rights reserved
  1122. X*/
  1123. X
  1124. X#define BASEYEAR 1970
  1125. X
  1126. X/****************
  1127. XFunction mstime() converts time in seconds since January 1 of BASEYEAR
  1128. Xto MS-DOS format date and time.
  1129. X*/
  1130. Xmstime(longtime, date, time)
  1131. Xlong longtime;       /* input:  seconds since Jan 1, BASEYEAR   */
  1132. Xint *date, *time;    /* output: MS-DOS format date and time */
  1133. X
  1134. X{
  1135. X   static int daysinmo[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  1136. X#define FEBRUARY 1
  1137. X   int year, month, day, hour, min, sec;
  1138. X   long secsinhour, secsinday, secsinyear, secsinleapyear;
  1139. X
  1140. X   int leapyear;                             /* is this a leap year? */
  1141. X   int done;                                 /* control variable */
  1142. X
  1143. X   secsinhour = (long) (60 * 60);            /* seconds in an hour */
  1144. X   secsinday  = 24 * secsinhour;             /* seconds in a day */
  1145. X   secsinyear = 365 * secsinday;             /* seconds in a year */
  1146. X   secsinleapyear = secsinyear + secsinday;  /* seconds in a leap year */
  1147. X
  1148. X#ifdef DEBUG
  1149. Xprintf("mstime:  input longtime = %ld\n", longtime);
  1150. X#endif
  1151. X
  1152. X   /* We can't handle dates before 1970 so force longtime positive */
  1153. X   if (longtime < 0)
  1154. X      longtime = 0;
  1155. X
  1156. X   /* 
  1157. X   Step through years from BASEYEAR onwards, subtracting number of
  1158. X   seconds in each, stopping just before longtime would become negative.
  1159. X   */
  1160. X   year = BASEYEAR;
  1161. X   done = 0;
  1162. X   while (!done) {
  1163. X      long yearlength;
  1164. X      leapyear = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
  1165. X      if (leapyear)
  1166. X         yearlength = secsinleapyear;
  1167. X      else
  1168. X         yearlength = secsinyear;
  1169. X
  1170. X      if (longtime >= yearlength) {
  1171. X         longtime -= yearlength;
  1172. X         year++;
  1173. X      } else
  1174. X         done++;
  1175. X   }
  1176. X
  1177. X   /* Now `year' contains year and longtime contains remaining seconds */
  1178. X   daysinmo[FEBRUARY] = leapyear ? 29 : 28;
  1179. X
  1180. X   month = 0; /* range is 0:11 */
  1181. X   while (longtime > daysinmo[month] * secsinday) {
  1182. X      longtime = longtime - daysinmo[month] * secsinday;
  1183. X      month++;
  1184. X   }
  1185. X   month++; /* range now 1:12 */
  1186. X
  1187. X   day = longtime / secsinday;     /* day of month, range 0:30 */
  1188. X   longtime = longtime % secsinday;
  1189. X   day++;                         /* day of month, range 1:31 */
  1190. X
  1191. X   hour = longtime / secsinhour;       /* hours, range 0:23 */
  1192. X   longtime = longtime % secsinhour;
  1193. X
  1194. X   min = longtime / 60L;               /* minutes, range 0:59 */
  1195. X   longtime = longtime % 60L;
  1196. X
  1197. X   sec = longtime;                     /* seconds, range 0:59 */
  1198. X
  1199. X#ifdef DEBUG
  1200. Xprintf("mstime:  date = %4d/%02d/%02d   time = %02d:%02d:%02d\n",
  1201. X      year, month, day, hour, min, sec);
  1202. Xif (leapyear)
  1203. X   printf("(leap year)\n");
  1204. X#endif
  1205. X
  1206. X   if (year < 1980)
  1207. X      year = 1980;
  1208. X   *date = day + (month << 5) + ((year - 1980) << 9);
  1209. X   *time = (sec / 2) + (min << 5) + (hour << 11);
  1210. X}
  1211. END_OF_FILE
  1212. if test 2860 -ne `wc -c <'mstime.i'`; then
  1213.     echo shar: \"'mstime.i'\" unpacked with wrong size!
  1214. fi
  1215. # end of 'mstime.i'
  1216. fi
  1217. if test -f 'nixtime.i' -a "${1}" != "-c" ; then 
  1218.   echo shar: Will not clobber existing file \"'nixtime.i'\"
  1219. else
  1220. echo shar: Extracting \"'nixtime.i'\" \(3434 characters\)
  1221. sed "s/^X//" >'nixtime.i' <<'END_OF_FILE'
  1222. X#ifndef LINT
  1223. Xstatic char nixtimeid[]="@(#) nixtime.i 2.3 88/01/24 12:49:28";
  1224. X#endif /* LINT */
  1225. X
  1226. X/*
  1227. XTime handling routines for UNIX systems.  These are included by the file
  1228. Xmachine.c as needed.
  1229. X
  1230. XThe contents of this file are hereby released to the public domain.
  1231. X
  1232. X                                    -- Rahul Dhesi  1986/12/31
  1233. X*/
  1234. X
  1235. Xstruct tm *localtime();
  1236. X
  1237. X/*****************
  1238. XFunction gettime() gets the date and time of the file handle supplied.
  1239. XDate and time is in MSDOS format.
  1240. X*/
  1241. Xint gettime (file, date, time)
  1242. XZOOFILE file;
  1243. Xunsigned *date, *time;
  1244. X{
  1245. X   struct stat buf;           /* buffer to hold file information */
  1246. X   struct tm *tm;             /* will hold year/month/day etc. */
  1247. X    int handle;
  1248. X    handle = fileno(file);
  1249. X   if (fstat (handle, &buf) == -1) {
  1250. X      prterror ('w', "Could not get file time\n");
  1251. X      *date = *time = 0;
  1252. X   } else {
  1253. X      tm = localtime (&buf.st_mtime); /* get info about file mod time */
  1254. X      *date = tm->tm_mday + ((tm->tm_mon + 1) << 5) +
  1255. X         ((tm->tm_year - 80) << 9);
  1256. X      *time = tm->tm_sec / 2 + (tm->tm_min << 5) +
  1257. X         (tm->tm_hour << 11);
  1258. X   }
  1259. X
  1260. X}
  1261. X
  1262. X/*****************
  1263. XFunction setutime() sets the date and time of the filename supplied.
  1264. XDate and time is in MSDOS format.  It assumes the existence of a function
  1265. Xmstonix() that accepts MSDOS format time and returns **IX format time,
  1266. Xand a function gettz() that returns the difference (localtime - gmt)
  1267. Xin seconds, taking daylight savings time into account.
  1268. X*/
  1269. Xint setutime(path,date,time)
  1270. Xchar *path;
  1271. Xunsigned int date, time;
  1272. X{
  1273. X    long mstonix();
  1274. X    long gettz();
  1275. X    long utimbuf[2];
  1276. X    utimbuf[0] = utimbuf[1] = gettz() + mstonix (date, time);
  1277. X    return (utime (path, utimbuf));
  1278. X}
  1279. X
  1280. X/****************
  1281. XFunction mstonix() accepts an MSDOS format date and time and returns
  1282. Xa **IX format time.  No adjustment is done for timezone.
  1283. X*/
  1284. X
  1285. Xlong mstonix (date, time)
  1286. Xunsigned int date, time;
  1287. X{
  1288. X   int year, month, day, hour, min, sec, daycount;
  1289. X   long longtime;
  1290. X   /* no. of days to beginning of month for each month */
  1291. X   static int dsboy[12] = { 0, 31, 59, 90, 120, 151, 181, 212,
  1292. X                              243, 273, 304, 334};
  1293. X
  1294. X   if (date == 0 && time == 0)            /* special case! */
  1295. X      return (0L);
  1296. X
  1297. X   /* part of following code is common to zoolist.c */
  1298. X   year  =  (((unsigned int) date >> 9) & 0x7f) + 1980;
  1299. X   month =  ((unsigned int) date >> 5) & 0x0f;
  1300. X   day   =  date        & 0x1f;
  1301. X
  1302. X   hour =  ((unsigned int) time >> 11)& 0x1f;
  1303. X   min   =  ((unsigned int) time >> 5) & 0x3f;
  1304. X   sec   =  ((unsigned int) time & 0x1f) * 2;
  1305. X
  1306. X/*
  1307. XDEBUG and leap year fixes thanks to Mark Alexander 
  1308. X<uunet!amdahl!drivax!alexande>
  1309. X*/
  1310. X#ifdef DEBUG
  1311. X   printf ("mstonix:  year=%d  month=%d  day=%d  hour=%d  min=%d  sec=%d\n",
  1312. X           year, month, day, hour, min, sec);
  1313. X#endif
  1314. X
  1315. X   /* Calculate days since 1970/01/01 */
  1316. X   daycount = 365 * (year - 1970) +    /* days due to whole years */
  1317. X               (year - 1969) / 4 +     /* days due to leap years */
  1318. X               dsboy[month-1] +        /* days since beginning of this year */
  1319. X               day-1;                  /* days since beginning of month */
  1320. X
  1321. X   if (year % 4 == 0 && 
  1322. X       year % 400 != 0 && month >= 3)  /* if this is a leap year and month */
  1323. X      daycount++;                      /* is March or later, add a day */
  1324. X
  1325. X   /* Knowing the days, we can find seconds */
  1326. X   longtime = daycount * 24L * 60L * 60L    +
  1327. X          hour * 60L * 60L   +   min * 60   +    sec;
  1328. X    return (longtime);
  1329. X}
  1330. END_OF_FILE
  1331. if test 3434 -ne `wc -c <'nixtime.i'`; then
  1332.     echo shar: \"'nixtime.i'\" unpacked with wrong size!
  1333. fi
  1334. # end of 'nixtime.i'
  1335. fi
  1336. if test -f 'options.h' -a "${1}" != "-c" ; then 
  1337.   echo shar: Will not clobber existing file \"'options.h'\"
  1338. else
  1339. echo shar: Extracting \"'options.h'\" \(5008 characters\)
  1340. sed "s/^X//" >'options.h' <<'END_OF_FILE'
  1341. X/* @(#) options.h 2.22 88/08/24 15:27:36 */
  1342. X
  1343. X/*
  1344. XThe contents of this file are hereby released to the public domain.
  1345. X
  1346. X                           -- Rahul Dhesi 1986/11/14
  1347. X
  1348. XFor documentation about this file, see options.doc.
  1349. X*/
  1350. X
  1351. X
  1352. X/* ZOO is always defined currently */
  1353. X#define ZOO
  1354. X
  1355. X/* Compilation without ZOOCOMMENT has not been tested */
  1356. X#define ZOOCOMMENT
  1357. X
  1358. X#ifdef SYS_V
  1359. X#define FILTER
  1360. X#define VER_DISPLAY ";"
  1361. X#define VER_INPUT ":;"
  1362. X#define IO_MACROS
  1363. X#define EXISTS(f)        (access(f, 00) == 0)
  1364. X#define MEMSET
  1365. X#define FNLIMIT 14
  1366. X#define CHEKDIR
  1367. X#define NIXTIME
  1368. X#define NIXFNAME
  1369. X#define NEEDCTYP
  1370. X#define NOENUM
  1371. X#define PORTABLE
  1372. X#define REN_LINK
  1373. X#define SETBUF
  1374. X#define GETTZ
  1375. X#define FATTR
  1376. X#endif
  1377. X
  1378. X#ifdef TURBOC
  1379. X#define VER_DISPLAY ";"
  1380. X#define VER_INPUT ":;"
  1381. X#define USE_ASCII
  1382. X#define SPECINIT
  1383. X#define SPECEXIT
  1384. X#define PURIFY
  1385. X#define DISK_CH ':'
  1386. X#define IGNORECASE
  1387. X#define WILDCARD "*.*"
  1388. X#define FOLD
  1389. X#define FORCESLASH
  1390. X#define FNLIMIT 12
  1391. X#define CUR_DIR "."
  1392. X#define PATH_CH "/"
  1393. X#define PATH_SEP ":/\\"
  1394. X#define EXT_CH '.'
  1395. X#define EXT_SEP  ":/\\."
  1396. X#define EXT_DFLT ".zoo"
  1397. X#define SETMODE
  1398. X/* 0x8000 and 0x4000 taken from <fcntl.h> for Turbo C */
  1399. X#define MODE_BIN(f)      setmode(fileno(f), 0x8000)
  1400. X#define MODE_TEXT(f)     setmode(fileno(f), 0x4000)
  1401. X#define LINT_ARGS
  1402. X#define MORE     ...
  1403. X#define NOTHING        void
  1404. X#define VOIDPTR        void *
  1405. X#define REN_REV
  1406. X#define UNBUF_IO
  1407. X#define UNBUF_LIMIT        512
  1408. X#ifdef  PORTABLE
  1409. X#define SPECNEXT
  1410. X#define NIXTIME
  1411. X#undef  WILDCARD
  1412. X#endif
  1413. X
  1414. X#endif /* TURBOC */
  1415. X
  1416. X#ifdef MSC
  1417. X#define VER_DISPLAY ";"
  1418. X#define VER_INPUT ":;"
  1419. X#define ALWAYS_INT
  1420. X#define USE_ASCII
  1421. X#define SPECINIT
  1422. X#define SPECEXIT
  1423. X#define PURIFY
  1424. X#define DISK_CH ':'
  1425. X#define IGNORECASE
  1426. X#define WILDCARD "*.*"
  1427. X#define FOLD
  1428. X#define FORCESLASH
  1429. X#define FNLIMIT 12
  1430. X#define CUR_DIR "."
  1431. X#define PATH_CH "/"
  1432. X#define PATH_SEP ":/\\"
  1433. X#define EXT_CH '.'
  1434. X#define EXT_SEP  ":/\\."
  1435. X#define EXT_DFLT ".zoo"
  1436. X#define SETMODE
  1437. X/* 0x8000 and 0x4000 taken from <fcntl.h> for Microsoft C */
  1438. X#define MODE_BIN(f)      setmode(fileno(f), 0x8000)
  1439. X#define MODE_TEXT(f)     setmode(fileno(f), 0x4000)
  1440. X#define LINT_ARGS
  1441. X#define MORE
  1442. X#define NOTHING
  1443. X#define VOIDPTR        char *
  1444. X#define REN_NORM
  1445. X
  1446. X#define UNBUF_IO
  1447. X#define UNBUF_LIMIT        512
  1448. X
  1449. X#ifdef  PORTABLE
  1450. X#define SPECNEXT
  1451. X#define NIXTIME
  1452. X#undef  WILDCARD
  1453. X#endif
  1454. X
  1455. X#endif /* MSC */
  1456. X
  1457. X#ifdef BSD4_3
  1458. X#define NOSTRCHR /* not really needed for 4.3BSD */
  1459. X#define FILTER
  1460. X#define VER_DISPLAY ";"
  1461. X#define VER_INPUT ":;"
  1462. X#define IO_MACROS
  1463. X#define EXISTS(f)        (access(f, 00) == 0)
  1464. X#define FNLIMIT 1023
  1465. X#define CHEKDIR
  1466. X#define NIXTIME
  1467. X#define NIXFNAME
  1468. X#define NEEDCTYP
  1469. X#define PORTABLE
  1470. X#define NOENUM
  1471. X#define REN_REV
  1472. X#define SETBUF
  1473. X#define GETTZ
  1474. X#define FATTR
  1475. X#endif
  1476. X
  1477. X
  1478. X
  1479. X#ifdef VMS
  1480. X
  1481. X/*
  1482. XSelect VMS pre-4.6 or 4.6 next line.  Pre-4.6 library does not have
  1483. Xrename() and memset() so zoo defines its own;  4.6 has these, so we
  1484. Xmust use them, else VMS library functions will conflict with our
  1485. Xown.
  1486. X*/
  1487. X# if 1        /* VMS version 4.6 */
  1488. X#  define VMS_RENAME /* this symbol used only in file vms.c */
  1489. X#  define REN_REV
  1490. X#  define MEMSET
  1491. X# else        /* VMS pre-version 4.5 */
  1492. X#  define REN_NORM
  1493. X# endif
  1494. X
  1495. X#define VER_DISPLAY ";"
  1496. X#define VER_INPUT ":;"
  1497. X
  1498. X#define IO_MACROS
  1499. X#define SPEC_WILD
  1500. X#define EXT_ANYWAY
  1501. X#define VER_CH ';'
  1502. X#define SPECEXIT
  1503. X#define CHEKUDIR
  1504. X#define FNLIMIT 78
  1505. X#define DIR_SEP '.'  /* separates dir fields */
  1506. X#define DISK_CH ':'
  1507. X#define DIR_LBRACK "[" /* left bracketing symbol dir dir name */
  1508. X#define PATH_CH "]"
  1509. X#define PATH_SEP ":]"
  1510. X#define EXT_CH '.'
  1511. X#define EXT_SEP ":]."
  1512. X#define EXT_DFLT ".zoo"
  1513. X#define CUR_DIR "."
  1514. X#define NIXTIME
  1515. X#define NEEDCTYP
  1516. X#define NOENUM
  1517. X#define PORTABLE
  1518. X#define DUMB_ASS
  1519. X#define IGNORECASE
  1520. X#define SPECMOD
  1521. X#define SPECNEXT
  1522. X#define WILDCARD "*.*"
  1523. X#define FOLD
  1524. X#endif
  1525. X
  1526. X#ifdef MCH_AMIGA
  1527. X#define VER_DISPLAY ";"
  1528. X#define VER_INPUT ":;"
  1529. X#define PURIFY
  1530. X#define DISK_CH ':'
  1531. X#define SPECNEXT
  1532. X#define WILDCARD "*"
  1533. X#define IGNORECASE
  1534. X#define FNLIMIT 30
  1535. X#define NEEDCTYP
  1536. X#define CUR_DIR "."
  1537. X#define PATH_CH "/"
  1538. X#define PATH_SEP ":/"
  1539. X#define EXT_CH   '.'
  1540. X#define EXT_SEP  ":/."
  1541. X#define EXT_DFLT ".zoo"
  1542. X#define PORTABLE
  1543. X#define NOSIGNAL
  1544. X#define REN_REV
  1545. X#define NOENUM
  1546. X#define SETBUF
  1547. X#define CHEKUDIR
  1548. X#define GETUTIME
  1549. X#define NIXTIME
  1550. X#endif
  1551. X
  1552. X#ifdef NIXFNAME
  1553. X#define CUR_DIR "."
  1554. X#define PATH_CH "/"
  1555. X#define PATH_SEP "/"
  1556. X#define EXT_CH '.'
  1557. X#define EXT_SEP  "/."
  1558. X#define EXT_DFLT ".zoo"
  1559. X#endif
  1560. X
  1561. X#ifdef GENERIC
  1562. X/* #define SPECNEXT */
  1563. X#define IGNORECASE
  1564. X#define FNLIMIT 11
  1565. X#define NEEDCTYP
  1566. X#define CUR_DIR "."
  1567. X#define PATH_CH "/"
  1568. X#define PATH_SEP ":/"
  1569. X#define EXT_CH   '.'
  1570. X#define EXT_SEP  ":/."
  1571. X#define EXT_DFLT ".zoo"
  1572. X#define PORTABLE
  1573. X#define NOSIGNAL
  1574. X/* REN_LINK is UNIX-specific.  Can't find a generic rename() function */
  1575. X#define REN_LINK
  1576. X/* #define FLAT */
  1577. X#define NOENUM
  1578. X#define SETBUF
  1579. X#define CHEKUDIR
  1580. X#define GETUTIME
  1581. X#define NIXTIME
  1582. X#endif
  1583. X
  1584. X/* ANSI compatibility in declarations -- see zoofns.h for usage */
  1585. X#ifndef PARMS
  1586. X#ifdef LINT_ARGS
  1587. X#define    PARMS(x)        x
  1588. X#else
  1589. X#define    PARMS(x)        ()
  1590. X#endif
  1591. X#endif
  1592. X
  1593. X/* Compensate for strchr/index differences */
  1594. X#ifdef NOSTRCHR
  1595. X#define    strchr    index
  1596. X#define    strrchr    rindex
  1597. X#endif
  1598. END_OF_FILE
  1599. if test 5008 -ne `wc -c <'options.h'`; then
  1600.     echo shar: \"'options.h'\" unpacked with wrong size!
  1601. fi
  1602. # end of 'options.h'
  1603. fi
  1604. if test -f 'zoofns.h' -a "${1}" != "-c" ; then 
  1605.   echo shar: Will not clobber existing file \"'zoofns.h'\"
  1606. else
  1607. echo shar: Extracting \"'zoofns.h'\" \(3138 characters\)
  1608. sed "s/^X//" >'zoofns.h' <<'END_OF_FILE'
  1609. X/* @(#) zoofns.h 2.5 88/01/16 19:03:13 */
  1610. X/* @(#) zoofns.h 2.7 88/01/27 19:39:18 */
  1611. X
  1612. X/*
  1613. XThe contents of this file are hereby released to the public domain.
  1614. X
  1615. X                           -- Rahul Dhesi 1986/11/14
  1616. X*/
  1617. X
  1618. X/* Defines function declarations for all Zoo functions */
  1619. X
  1620. X#ifndef PARMS
  1621. X#ifdef LINT_ARGS
  1622. X#define    PARMS(x)        x
  1623. X#else
  1624. X#define    PARMS(x)        ()
  1625. X#endif
  1626. X#endif
  1627. X
  1628. X/* 
  1629. X:.,$s/(PARMS\(.*\));/PARMS\1;/
  1630. X*/
  1631. Xlong calc_ofs PARMS ((char *));
  1632. Xchar *addext PARMS ((char *, char *));
  1633. Xchar *combine PARMS ((char[], char *, char *));
  1634. Xchar *emalloc PARMS ((unsigned int));
  1635. Xchar *erealloc PARMS ((char *, unsigned int));
  1636. Xchar *findlast PARMS ((char *, char *));
  1637. Xchar *fixfname PARMS ((char *));
  1638. Xchar *getstdin PARMS ((NOTHING));
  1639. Xchar *lastptr PARMS ((char *));
  1640. Xchar *nameptr PARMS ((char *));
  1641. Xchar *newcat PARMS ((char *, char *));
  1642. Xchar *memset PARMS ((char *, int, unsigned));
  1643. Xchar *nextfile PARMS ((int, char *, int));
  1644. Xint cfactor PARMS ((long, long));
  1645. Xint chname PARMS ((char *, char *));
  1646. Xint cmpnum PARMS ((unsigned int, unsigned int, unsigned int, unsigned int));
  1647. Xint ctrl_c PARMS ((NOTHING));
  1648. Xint exists PARMS ((char *));
  1649. Xint getfile PARMS ((ZOOFILE, ZOOFILE, long, int));
  1650. Xint getutime PARMS ((char *, unsigned *, unsigned *));
  1651. Xint gettime PARMS ((ZOOFILE, unsigned *, unsigned *));
  1652. Xint handle_break PARMS ((NOTHING));
  1653. X
  1654. X#ifdef USE_ASCII
  1655. Xint isupper PARMS ((char));
  1656. Xint isdigit PARMS ((char));
  1657. X#endif /* USE_ASCII */
  1658. X
  1659. Xint kill_files PARMS ((char *[], int));
  1660. X#ifdef UNBUF_IO
  1661. Xint lzc PARMS ((int, int));
  1662. Xint lzd PARMS ((int, int));
  1663. X#else
  1664. Xint lzc PARMS ((ZOOFILE, ZOOFILE));
  1665. Xint lzd PARMS ((ZOOFILE, ZOOFILE));
  1666. X#endif
  1667. Xint match_half PARMS ((char *, char *));
  1668. Xint samefile PARMS ((char *, char *));
  1669. Xint settime PARMS ((ZOOFILE, unsigned, unsigned));
  1670. Xint setutime PARMS ((char *, unsigned, unsigned));
  1671. Xint strcmpi PARMS ((char *, char *));
  1672. X
  1673. X#ifdef USE_ASCII
  1674. Xint tolower PARMS ((char));
  1675. Xint toascii PARMS ((char));
  1676. X#endif /* USE_ASCII */
  1677. X
  1678. Xint zooexit PARMS ((int));
  1679. Xlong inlist PARMS ((char *, unsigned int *, unsigned int *, unsigned *,
  1680. X                    unsigned *, unsigned *, long *, int));
  1681. Xunsigned long space PARMS ((int, int *));
  1682. Xvoid addbfcrc PARMS ((char *, int));
  1683. Xvoid addfname PARMS ((char *, long, unsigned int, unsigned int, 
  1684. X                            unsigned, unsigned));
  1685. Xvoid add_version PARMS ((char *, struct direntry *));
  1686. Xvoid basename PARMS ((char *, char []));
  1687. Xvoid break_off PARMS ((NOTHING));
  1688. Xvoid close_file PARMS ((ZOOFILE));
  1689. Xvoid comment PARMS ((char *, char *));
  1690. Xvoid extension PARMS ((char *, char []));
  1691. Xvoid exit PARMS ((int));
  1692. Xvoid fixslash PARMS ((char *));
  1693. Xvoid makelist PARMS ((int, char *[], char *[], int, char *, char *, char *, int *));
  1694. Xvoid memerr PARMS ((NOTHING));
  1695. Xvoid prterror PARMS ((int, char *, MORE));
  1696. Xvoid rootname PARMS ((char *, char *));
  1697. Xvoid skip_files PARMS ((ZOOFILE, unsigned int *, unsigned int *, int *,
  1698. X                  char [], long *));
  1699. Xvoid writenull PARMS ((ZOOFILE, int));
  1700. Xvoid zooadd PARMS ((char *, int, char **, char *));
  1701. Xvoid zoodel PARMS ((char *, char *, int));
  1702. Xvoid zoofilt PARMS ((char *));
  1703. Xvoid zooext PARMS ((char *, char *));
  1704. Xvoid zoolist PARMS ((char **, char *, int));
  1705. Xvoid zoopack PARMS ((char *, char *));
  1706. END_OF_FILE
  1707. if test 3138 -ne `wc -c <'zoofns.h'`; then
  1708.     echo shar: \"'zoofns.h'\" unpacked with wrong size!
  1709. fi
  1710. # end of 'zoofns.h'
  1711. fi
  1712. echo shar: End of archive 2 \(of 10\).
  1713. cp /dev/null ark2isdone
  1714. MISSING=""
  1715. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1716.     if test ! -f ark${I}isdone ; then
  1717.     MISSING="${MISSING} ${I}"
  1718.     fi
  1719. done
  1720. if test "${MISSING}" = "" ; then
  1721.     echo You have unpacked all 10 archives.
  1722.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1723. else
  1724.     echo You still need to unpack the following archives:
  1725.     echo "        " ${MISSING}
  1726. fi
  1727. ##  End of shell archive.
  1728. exit 0
  1729.